#ifndef  _globalvar_debug_h_
#define  _globalvar_debug_h_

extern volatile unsigned long lDebugIntState;

#ifdef _DEBUG_
#define 		_INTSTATE_MASK(a)   	{ lDebugIntState |= ( (unsigned long )1<< a);}
#define 		_INTSTATE_REMASK(a)   { lDebugIntState &= ~( (unsigned long )1<< a);} 
#define 		_ISINTSTATE()   ( lDebugIntState )
#else
#define 		_INTSTATE_MASK(a)   	{}
#define 		_INTSTATE_REMASK(a)   {}
#define 		_ISINTSTATE()   ( 0 )
#endif

enum ENUMINTSTAT
{
  _DMA1_Channel4_IRQHandler_ = 0,	//; DMA1 Channel 4
  _USART1_IRQHandler_,		//; USART1
  
  _NMI_Handler_,		//  ; NMI Handler
  _HardFault_Handler_,		//; Hard Fault Handler
  _MemManage_Handler_,		//; MPU Fault Handler
  _BusFault_Handler_,		// ; Bus Fault Handler
  _UsageFault_Handler_,		//; Usage Fault Handler
  _SVC_Handler_,		//  ; SVCall Handler
  _DebugMon_Handler_,		// ; Debug Monitor Handler
  _PendSV_Handler_,		//   ; PendSV Handler
  _SysTick_Handler_,		//  ; SysTick Handler
  _WWDG_IRQHandler_,		//  ; Window Watchdog
  _PVD_IRQHandler_,		//   ; PVD through EXTI Line detect
  _TAMPER_IRQHandler_,		//; Tamper
  _RTC_IRQHandler_,		//   ; RTC
  _FLASH_IRQHandler_,		// ; Flash
  _RCC_IRQHandler_,		//   ; RCC
  _EXTI0_IRQHandler_,		// ; EXTI Line 0
  _EXTI1_IRQHandler_,		// ; EXTI Line 1
  _EXTI2_IRQHandler_,		// ; EXTI Line 2
  _EXTI3_IRQHandler_,		// ; EXTI Line 3
  _EXTI4_IRQHandler_,		// ; EXTI Line 4
  _DMA1_Channel1_IRQHandler_,	//; DMA1 Channel 1
  _DMA1_Channel2_IRQHandler_,	//; DMA1 Channel 2
  _DMA1_Channel3_IRQHandler_,	//; DMA1 Channel 3
//_DMA1_Channel4_IRQHandler_,//; DMA1 Channel 4
  _DMA1_Channel5_IRQHandler_,	//; DMA1 Channel 5
  _DMA1_Channel6_IRQHandler_,	//; DMA1 Channel 6
  _DMA1_Channel7_IRQHandler_,	//; DMA1 Channel 7
  _ADC1_IRQHandler_,		//  ; ADC1
  _USB_HP_IRQHandler_,		//; USB High Priority
  _USB_LP_IRQHandler_,		//; USB Low  Priority
  _EXTI9_5_IRQHandler_,		//; EXTI Line 9..5
  _TIM2_IRQHandler_,		//  ; TIM2
  _TIM3_IRQHandler_,		//  ; TIM3
  _TIM4_IRQHandler_,		//  ; TIM4
  _I2C1_EV_IRQHandler_,		//; I2C1 Event
  _I2C1_ER_IRQHandler_,		//; I2C1 Error
  _I2C2_EV_IRQHandler_,		//; I2C2 Event
  _I2C2_ER_IRQHandler_,		//; I2C2 Error
  _SPI1_IRQHandler_,		//  ; SPI1
  _SPI2_IRQHandler_,		//  ; SPI2
//	_USART1_IRQHandler_,//; USART1
  _USART2_IRQHandler_,		//; USART2
  _USART3_IRQHandler_,		//; USART3
  _EXTI15_10_IRQHandler_,	//    ; EXTI Line 15..10
  _RTC_Alarm_IRQHandler_,	//     ; RTC Alarm through EXTI Line
  _USBWakeUp_IRQHandler_,	//    ; USB Wakeup from suspend
	_Can_IRQHandler_,
  _Vectors_End_,
};


enum ENUMERRNO
{
	_debug_errno_start = _Vectors_End_ +1,
  _debug_errno_null_,
  _debug_errno_resetvector_,
  _debug_errno_wdgout_,		//debug_break(_debug_errno_wdgout_);
  _debug_errno_wdginterrupt_,
  _debug_errno_flashdatarestore_,
  _debug_errno_prog_reset_,
  _debug_errno_harfault_,	//debug_break(_debug_errno_harfault_);
  _debug_errno_NMI_Handler_,
  _debug_errno_SVC_Handler_,
  _debug_errno_PendSV_Handler_,
  _debug_errno_DebugMon_Handler_,
  _debug_errno_MemManage_Handler_,
  _debug_errno_BusFault_Handler_,
  _debug_errno_UsageFault_Handler_,
  _debug_errno_Call_Null_,
  _debug_errno_LcdSegit_OverMem_,
  _debug_Error_Handler_,
  _debug_DMA1_Channel4_IRQHandler1,
	_debug_errno_ShowFun_,
	 _debug_IdelCallback_App_,
	 _debug_modbusTask_,
	 _debug_CAN_ReceTimeout_,
	 _debug_V9420_ErrInc_,
	 _debug_V9420_ReadCrcError_, 
	 _debug_PowerUp_,
_debug_I2c_ERROR_,
  _debug_uartreconfig_,
  _debug_app_uart0_int_,
  _debug_app_uart0_ErrorCallback_int_,
  _debug_app_uart1_int_,
  _debug_app_uart1_ErrorCallback_int_,
  _debug_app_uart2_int_,
	_debug_app_uart2_Rx_,
	_debug_app_uart2_Rx1_,
  _debug_app_uart2_ErrorCallback_int_,
  _debug_app_uart3_int_,
  _debug_app_uart3_ErrorCallback_int_,
  _debug_app_uart4_int_,
  _debug_app_uart4_ErrorCallback_int_,
  _debug_app_uart5_int_,
  _debug_app_uart5_ErrorCallback_int_,
	 _debug_app_Forze_LineLoad_,
_dbug_Rm8025_NoItit_,
  _debug_Rm8025_ReadHandler_,
	  _debug_Rm8025_Error_,
 _debug_DB18B20_CheckFail_,
  _debug_USART1_IRQHandler_1_,
  _debug_USART1_IRQHandler_2_,
  _debug_USART1_IRQHandler_3_,
  _debug_UART_DMATransmitCplt_, 
  _debug_sysmainfun_, 
	_debug_Adc_init_,
  _debug_app_nobreak_,		//==================
	_debug_Gprs_Comm_Error_,
	_debug_Gprs_sCgattstate_OverMax_,
 _debug_Gprs_Dete_OverMax_,
 _debug_Gprs_sig_check_OverMax_,
 _debug_Gprs_answer_timeout_,
 _debug_Gprs_qgnssts_answer_,
 _debug_app_TimeUpdate_,
 _debug_enGprsState_CmdInit_,
 _debug_app_reformatexteeprom_,
  _debug_app_TimechangeFroze_Get_,
  _debug_app_systemrunfroze_Push_,
  _debug_app_ModifyTime_,
  _debug_app_timechangefroze_push_,
  _debug_errno_SysTick_Handler_,
  _debug_Usart_Dma_Rece_Handler_,
  _debug_HAL_UART_RxCpltCallback_,
  _debug_bkbuf_receerror ,
  _debug_bkbuf_full_,
  _debug_bkbuf_temp_,
  _debug_bkbuf_checkerror_, 
  _debug_aroundmode_slave_run_recetimeout_,	// debug_break(_debug_aroundmode_slave_run_recetimeout_);
  _debug_aroundmode_slave_run_rececheckt_,	// debug_break(_debug_aroundmode_slave_run_rececheckt_);
  _debug_gprs_changeto_master_,	// debug_break(_debug_gprs_changeto_master_),
  _debug_gprs_changeto_master645_,	// debug_break(_debug_gprs_changeto_master645_),
  _debug_gprs_changeto_ftp_,	// debug_break(_debug_gprs_changeto_ftp_),
  _debug_gprs_changeto_slave_,	// debug_break(_debug_gprs_changeto_slave_),
  _debug_gprs_location_success_,	// debug_break(_debug_gprs_changeto_slave_),
  _debug_gprs_distance_over_,	// debug_break(_debug_gprs_distance_over_);
  _debug_gprs_nolink_too_long_,	// debug_break(_debug_gprs_nolink_too_long_)
  _debug_gprs_ftp_too_long_,	// debug_break(_debug_gprs_ftp_too_long_)
  _debug_gprs_nocomm_too_long_,	// debug_break(_debug_gprs_nocomm_too_long_)
  _debug_gprs_rece_answer_,	//debug_break(_debug_gprs_rece_answer_);
  _debug_gprs_changeto_mainremporttime_,	// debug_break(_debug_gprs_changeto_mainremporttime_),
  _debug_gprs_master_around_over_,	//debug_break(_debug_gprs_master_around_over_);
  _debug_RTC_Second_,		//debug_break(_debug_RTC_Second_);
  _debug_RTC_Alarm_,		//debug_break(_debug_RTC_Alarm_);
  _debug_Gprs_ftpend_,
  _debug_Gprs_ftptimeout_,
#ifdef _freertosuse_
  _debug_EchipTskFun_,
  _debug_ModBusTskFun_,
  _debug_MainTskFun_,
	_debug_TimeReInto_,
#endif
  _debug_errno_end_,
};

#ifdef _DEBUG_
void debug_break (enum ENUMERRNO ierrno);
void debugset (void) ;
/*
#define	_debugset()			{DBGMCU->APB1FZ |=  DBGMCU_APB1_FZ_DBG_WWDG_STOP|DBGMCU_APB1_FZ_DBG_IWDG_STOP|DBGMCU_APB1_FZ_DBG_TIM2_STOP|DBGMCU_APB1_FZ_DBG_TIM3_STOP ; \
				HAL_DBGMCU_EnableDBGStopMode();DBGMCU->APB2FZ |= DBGMCU_APB2_FZ_DBG_TIM1_STOP|DBGMCU_APB2_FZ_DBG_TIM16_STOP; }
*/
#define	_debugstm32G030()  {}
#else
#define	debug_break(a)		{}
#define	debugset()		{}
#endif
	
	void debug_pin1(void);
void debug_pin2(void);
	void debug_printfMem(char *sPrev, char *datap,unsigned char clen,char *sSucc);
	void debug_printfs(char *sPrev, char *sdata,char *sSucc);
	void debug_printfd(char *sPrev, unsigned short iData,char *sSucc);
    
void debug_printfl(char *sPrev, unsigned long lData,char *sSucc);
	
	#define SEGGER_RTT_printf   //  
#endif
